
void QuickSort(int *arr, int *left, int *right)
{
	int Key = *left;
	int *p1 = left;
	int *p2 = right;

	while (p1 < p2)
	{
		while (p1 < p2 && *p2 >= Key)
			--p2;
		while (p1 < p2 && *p1 <= Key)
			++p1;
		if (*p1 != *p2)
			swap(*p1, *p2); 
	}
	if (left < right)
	{
		swap(*left, *p1);
		QuickSort(arr, left, p1 - 1);
		QuickSort(arr, p1 + 1, right);
	}
}

//算法导论写法
void QuickSort_(int *arr, int *left, int *right)
{
	if (left >= right)
		return;
	int Key = *right;
	int *p1 = left;
	int *p2 = left - 1;
	for (; p1 != right; ++p1)
	{
		if (*p1 <= Key)
			if (++p2 != p1)
				swap(*p1, *p2);
	}
	swap(*(p2 + 1), *right);
	QuickSort_(arr, left, p2);
	QuickSort_(arr, p2 + 1, right);
}



